package com.limh.base.dao

import android.os.Parcel
import android.os.Parcelable

/**
 * @function：
 * @author： limh
 * @date： 2018/9/24
 * Copyright @2018 Corpration Name
 */
data class User(var userId: Long = 0, var userType: Int = 0, var userName: String = "", var password: String = "",
                var email: String = "", var phone: String = "", var userSex: String = "", var birthday: Long = 0, var imgUrl: String = "",
                var createAt: Long = 0, var updateAt: Long = 0):Parcelable{
    constructor(parcel: Parcel) : this(
            parcel.readLong(),
            parcel.readInt(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readLong(),
            parcel.readString(),
            parcel.readLong(),
            parcel.readLong()) {
    }

    override fun toString(): String {
        return "User(userId=$userId, userType=$userType, userName='$userName', password='$password', email='$email', phone='$phone', userSex='$userSex', birthday=$birthday, imgUrl='$imgUrl', createAt=$createAt, updateAt=$updateAt)"
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(userId)
        parcel.writeInt(userType)
        parcel.writeString(userName)
        parcel.writeString(password)
        parcel.writeString(email)
        parcel.writeString(phone)
        parcel.writeString(userSex)
        parcel.writeLong(birthday)
        parcel.writeString(imgUrl)
        parcel.writeLong(createAt)
        parcel.writeLong(updateAt)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<User> {
        override fun createFromParcel(parcel: Parcel): User {
            return User(parcel)
        }

        override fun newArray(size: Int): Array<User?> {
            return arrayOfNulls(size)
        }
    }
}